// @ts-nocheck
//1. 引入
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import Login from '@/views/login'
import Test from '@/views/Test'
import Layout from '@/views/layout'
import Home from '@/views/home'
import Qa from '@/views/qa'
import Video from '@/views/video'
import My from '@/views/my'
// import Article from '@/views/article'

// const Article = () => import('@/views/article')

//2. 创建
const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/layout/home' },
    { path: '/login', name: 'login', component: () => import('@/views/login') },
    {
      path: '/layout',
      name: 'layout',
      component: Layout,
      children: [
        { path: 'home', name: 'home', component: () => import('@/views/home') },
        { path: 'qa', name: 'qa', component: Qa },
        { path: 'video', name: 'video', component: Video },
        { path: 'my', name: 'my', component: My },
      ],
    },
    {
      path: '/article/:articleId',
      name: 'article',
      component: () => import('@/views/article'),
      props: true,
    },
    {
      path: '/user/profile',
      name: 'profile',
      component: () => import('@/views/user-profile'),
    },

    // 这是一个测试
    { path: '/test', name: 'test', component: Test },
  ],
})

// 这段不要关注什么意思
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

//3. 挂载
export default router
